{include file="top.html"}
<script type="text/javascript">
    var shippings = {$shippings};
    var addresses = {$addresses};
    var goods_amount = {$goods_info.amount};
    var goods_quantity = {$goods_info.quantity};;
$(function(){
    $('ul[shipping_id]').each(function() {
        var _shipping_fee = get_shipping_fee($(this).attr('shipping_id'));
        $(this).find('[ectype="shipping_fee"]').html(price_format(_shipping_fee));
    }).click(function() {
        set_order_amount($(this).attr('shipping_id'));
    });
    //select first
    set_order_amount($($('ul[shipping_id]')[0]).attr('shipping_id'));
    
});
function set_order_amount(shipping_id) {
    var _shipping_fee = get_shipping_fee(shipping_id);
    var _amount = goods_amount + _shipping_fee;
    $('#order_amount').html(price_format(_amount));
}
function get_shipping_fee(shipping_id) {
    var shipping_data = shippings[shipping_id];
    var first_price = Number(shipping_data['first_price']);
    var step_price = Number(shipping_data['step_price']);
    return first_price + (goods_quantity - 1) * step_price;
}
function check_phone() {
    return ($('#phone_tel').val() == '' && $('#phone_mob').val() == '');
}
function hide_error() {
    $('#region').find('.error').hide();
}

</script>

<div id="main"  data-role="page">
  <!--common bar start-->
	<div class="bar-wrap {if $smarty.get.app eq 'member' && $smarty.get.act eq ''}w{/if}">
		<div class="top-bar"> <a href="{if $smarty.get.act eq '' && $smarty.get.app neq 'member'}{url app=member}{elseif $smarty.get.app eq 'member' &&  $smarty.get.act eq ''}mobile/index.php{else}javascript:pageBack();{/if}" class="pageback"><span></span></a>
			<h2 class="yahei">{$lang.confirm_order}</h2>
			<a href="javascript:;" class="pagemore J_pagemore"><span></span></a>
	    </div>
		<div class="eject-tab J_eject_tab w-full clearfix hidden">
			 <a href="index.php"> <span></span>
			<p>首页</p>
			</a> <a href="{url app=search}"> <span class="icon2"></span>
			<p>分类搜索</p>
			</a> <a href="{url app=cart}"> <span class="icon3"></span>
			<p>购物车</p>
			</a> <a href="{url app=member}"> <span class="icon4"></span>
			<p>用户中心</p>
			</a> 
		 </div>
	</div>
   <!--common bar end-->
  <form method="post" id="order_form">
    <div class="page-order" id="page-order"> 
	{include file="order.shipping.html"}
      {include file="order.goods.html"}
      {include file="order.amount.html"} </div>
  </form>
  {include file="footer.html"} </div>
<div style="background:#F1F1F1" class="more-addr" data-role="page" id="more-addr"> 
  <!--{foreach from=$my_address item=address name=address_select}-->
  <div class="post-addr {if $smarty.foreach.address_select.first}addr-selected{/if}" addr_id="{$address.addr_id}">
    <article class="wrap mt10">
      <ul>
        <li class="consignee">
          <div class="content-inline-list">
            <div class="content-title">收货信息</div>
            <div class="content-detail">{$address.consignee|escape} <!--{if $address.phone_mob}-->{$address.phone_mob}<!--{else}-->{$address.phone_tel}<!--{/if}--></div>
          </div>
        </li>
        <li class="address-content" >
          <div class="content-inline-list">
            <div class="content-title">收货地址：</div>
            <div class="content-detail"><span class="content-detail-addr">{$address.region_name|escape}&nbsp;&nbsp;  {$address.address|escape}</span><a data-transition="slide" href="#more-addr">
              <aside class="content-nav">&nbsp;</aside>
              </a></div>
          </div>
        </li>
      </ul>
    </article>
  </div>
  <!--{/foreach}--> 
  <a href="{$ret_url}" class="btn-white">添加新地址</a> </div>
	<div class="shipping-methods-list" id="shipping-methods-list" data-role="page"> 
	  <!--{foreach from=$shipping_methods item=shipping_method name=shipping_select}-->
	  <ul class="receive_add {if $smarty.foreach.shipping_select.first}active{/if}" shipping_id="{$shipping_method.shipping_id}">
		<li>{$shipping_method.shipping_name|escape}{$lang.shipping_fee}:&nbsp;<span class="money" ectype="shipping_fee">&yen; 0.00</span>
		  <aside class="content-nav">&nbsp;</aside>
		</li>
	  </ul>
	  <!--{/foreach}--> 
	</div>
	<a href="#main" data-transition="slide" id="J_back"></a> 
<script type="text/javascript">
		$("[name='address_options']").val($('#more-addr .post-addr').eq(0).attr('addr_id'));
		$('#more-addr .post-addr').click(function(){
			$('#J_back').trigger('click');
			$('.show-addr .J_addr'+$(this).attr('addr_id')).show().siblings().hide();
			$(this).addClass('addr-selected').siblings().removeClass('addr-selected');
			$("[name='address_options']").val($(this).attr('addr_id'));
		});
		$('.show-addr .address-content').click(function(){
			$('#J_other_addr').trigger('click');
		});
		
		$("[name='shipping_id']").val($('#shipping-methods-list .receive_add').eq(0).attr('shipping_id'));
		$('.order-goods-info .receive_add').click(function(){
			$('#J_shipping_list').trigger('click');
		});
		$('#shipping-methods-list .receive_add').click(function(){
			$('#J_back').trigger('click');
			$('.order-goods-info .J_shipping'+$(this).attr('shipping_id')).show().siblings().hide();
			$(this).addClass('active').siblings().removeClass('active');
			$("[name='shipping_id']").val($(this).attr('shipping_id'));
		});
</script> 